//
//  MyTableViewController.swift
//  Wechat1.0
//
//  Created by henaihan on 2017/11/6.
//  Copyright © 2017年 henaihan. All rights reserved.
//

import UIKit

class MyTableViewController: UITableViewController {

    let arr = [["钱包"],["收藏","相册","卡包","表情"],["设置"]]
    let imgArr = [["Walet.jpg"],["Favor.jpg","pic.jpg","card.jpg","smile.jpg"],["setting.jpg"]]
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tableView = UITableView.init(frame: UIScreen.main.bounds, style: UITableViewStyle.grouped)
        tableView.dataSource = self
        tableView.delegate = self
        view.addSubview(tableView)
    }
    
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 4
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 2 {
            return 4
        } else {
            return 1
        }
    }
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 0 {
            return 100
        } else {
            return 44
        }
    }
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 5
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell: UITableViewCell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
        
        if indexPath.section == 0 {
            let headImage: UIImageView = UIImageView.init(frame: CGRect(x: 10, y: 10, width: 80, height: 80))
            headImage.image = UIImage(named: "5.png")
            cell.contentView.addSubview(headImage)
            
            let label: UILabel = UILabel.init(frame: CGRect(x: 100, y: 25, width: 200, height: 20))
            label.text = "何乃涵"
            cell.contentView.addSubview(label)
            
            let accountLabel = UILabel.init(frame: CGRect(x: 100, y: 55, width: 200, height: 20))
            accountLabel.text = "微信ID：SeanCrimon"
            accountLabel.font = UIFont.systemFont(ofSize: 16)
            cell.contentView.addSubview(accountLabel)
            
            let label2 = UILabel.init(frame: CGRect(x: 352, y: 40, width: 15, height: 20))
            label2.text = "›"
            label2.font = UIFont.systemFont(ofSize: 28)
            label2.textColor = UIColor.darkGray
            cell.contentView.addSubview(label2)
        } else {
            let imageView = UIImageView.init(frame: CGRect(x: 10, y: 10, width: 24, height: 24))
            imageView.image = UIImage(named: imgArr[indexPath.section - 1][indexPath.row])
            cell.contentView.addSubview(imageView)
            
            let label = UILabel.init(frame: CGRect(x: 44, y: 12, width: 50, height: 20))
            label.text = arr[indexPath.section - 1][indexPath.row]
            cell.contentView.addSubview(label)
            
            let label2 = UILabel.init(frame: CGRect(x: 352, y: 12, width: 15, height: 20))
            label2.text = "›"
            label2.font = UIFont.systemFont(ofSize: 28)
            label2.textColor = UIColor.darkGray
            
            cell.contentView.addSubview(label2)
        }
        return cell
    }

    /*
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

        // Configure the cell...

        return cell
    }
    */

    /*
    // Override to support conditional editing of the table view.
    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            // Delete the row from the data source
            tableView.deleteRows(at: [indexPath], with: .fade)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
